package net.borderwars.vm;

import junit.framework.TestCase;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class VMCases extends TestCase {


    private VirtualMachine vm;

    protected void setUp() throws IOException {
        File f = new File("vm\\target\\test-classes\\net\\borderwars\\vm\\SomeClass.class");
        byte data[] = null;
        data = new byte[(int) f.length()];
        FileInputStream fis = new FileInputStream(f);
        fis.read(data);
        vm = new VirtualMachine("SomeClass", data, true);
    }

    protected void tearDown() {

    }

    public void test3Ticks() {
        int startSize = vm.getStack().size();
         System.out.println("Stack " + vm.getStack());
        VMState state = vm.tick();
        while(!state.isDone()){
            System.out.println("Stack " + vm.getStack());
            state = vm.tick();
        }

        assertTrue("Stack size started at 1 and ended at 1",startSize == vm.getStack().size());
    }
}